package com.xiaoai.io.bio4;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * @Author
 * @Date 2021-09-06 01:10
 */
public class ServerRunnableTarget implements Runnable{
    private Socket socket;

    public ServerRunnableTarget(Socket socket){
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            InputStream is = socket.getInputStream();
            BufferedReader bis = new BufferedReader(new InputStreamReader(is));
            String msg;
            while ((msg = bis.readLine()) != null ){
                System.out.println("服务器接收到:"+"["+Thread.currentThread().getName()+"]["+socket.toString()+"]：" + msg);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
